﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snowdreamist.Windows.Navigation.Primitives
{
    public class NavigateProcessorFactory
    {
        public NavigateProcessorFactory(
            NavigationHandlerRepository repository,
            NavigationHandlerSelector selector,
            NavigationHandlerInvoker invoker,
            NavigationSwitcher switcher
            )
        {
            this.Repository = repository;
            this.Selector = selector;
            this.Invoker = invoker;
            this.Switcher = switcher;
        }

        public NavigationHandlerRepository Repository { get; set; }

        public NavigationHandlerSelector Selector { get; set; }

        public NavigationHandlerInvoker Invoker { get; set; }

        public NavigationSwitcher Switcher { get; set; }

        public NavigateProcessor CreateProcessor(Session session)
        {
            if (session == null)
                throw new ArgumentNullException("session");
            if (this.Repository == null)
                throw new InvalidOperationException("Repository is null");
            if (this.Selector == null)
                throw new InvalidOperationException("Selector is null");
            if (this.Invoker == null)
                throw new InvalidOperationException("Invoker is null");
            if (this.Switcher == null)
                throw new InvalidOperationException("Switcher is null");

            return new NavigateProcessor(
                this.Repository,
                this.Selector,
                this.Invoker,
                this.Switcher,
                session);
        }
    }
}